package niit.game;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

public class Map {
	private Bitmap cloud, map;
	private float moveCloud, moveIsland;
	private Paint paintCloud;
	private GameView gameView;
	private int x, y = 0;

	public Map(GameView gameView, Bitmap map, Bitmap cloud) {
		this.gameView = gameView;
		this.map = map;
		this.cloud = cloud;
		paintCloud= new Paint();
		paintCloud.setAlpha(190);

	}

	public void onDraw(Canvas canvas) {

		moveIsland = moveIsland + 1;
		// calculate the wrap factor for matching image draw
		float newFarYisl = -(moveIsland - map.getHeight());
		// if we have scrolled all the way, reset to start
		if (newFarYisl <= 0) {
			moveIsland = 0;
			// only need one draw
			canvas.drawBitmap(map, 0, moveIsland, null);
		} else {
			canvas.drawBitmap(map, 0, moveIsland, null);
			canvas.drawBitmap(map, 0, -newFarYisl, null);
		}

		// cho may chay
		moveCloud = moveCloud + (float) 1.5;
		// calculate the wrap factor for matching image draw
		float newFarYcloud = -(moveCloud - cloud.getHeight());
		// if we have scrolled all the way, reset to start
		if (newFarYcloud <= 0) {
			moveCloud = 0;
			// only need one draw
			canvas.drawBitmap(cloud, 0, moveCloud, paintCloud);
		} else {
			canvas.drawBitmap(cloud, 0, moveCloud, paintCloud);
			canvas.drawBitmap(cloud, 0, -newFarYcloud, paintCloud);
		}
		
	}

}
